package com.erp.controller.baseDataController;

import com.erp.pojo.Depot;
import com.erp.service.baseDataService.DepotService;
import com.erp.utils.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by IntelliJ IDEA.
 * Author:${JayC}
 * Date:2019/1/18
 * Time:17:34
 */
@RestController
@RequestMapping("/Depot")
public class DepotController {


    @Autowired
    private DepotService depotService;

    //获得仓库列表
    @PostMapping("/getDepot")
    public Msg getDep(@RequestParam(name = "name", defaultValue = "") String name,
                      @RequestParam(name = "page") int page,
                      @RequestParam(name = "limit") int limit) {

        System.out.println(name);

        Msg msg = depotService.selectDepot(name, page, limit);
        return msg;

    }

    //删除仓库
    @DeleteMapping("/delDepot/{id}")
    public void delDepot(@PathVariable(name = "id")Long id){
        depotService.deleteDep(id);
    }

    //增加仓库
    @PostMapping("/insertDep")
    public void insertDep(Depot depot){
        depotService.insertDep(depot);
    }
}
